<?php

namespace app\index\controller;

use app\api\v1\controller\ApiBase;
use Redis\RedisPackage;
use think\cache\driver\Redis;
use think\Controller;
use think\Request;

class Index extends Controller
{
    public function index()
    {
        return $this->fetch('index');
    }

    //redis第三方扩展测试
    public function redis()
    {
        //new redis类
        $redis = new RedisPackage();
        //设置redis string缓存
        $redis->set('test1', 'this');
        //获取缓存
        echo $redis->get('test1');
    }

    //redis原生测试
    public function source()
    {
        //new redis类
        $redis = new \Redis();
        //连接redis服务器
        $redis->connect('127.0.0.1', 6379);
        //设置redis缓存
        $redis->set('test2', 'is');
        //读取缓存
        echo $redis->get('test2');
    }

    //tp5自带redis测试
    public function tpRedis()
    {
        //new redis类
        $redis = new Redis();
        //检测是否连接成功
        echo "connectt server success";
        //设置缓存
        $redis->set('huancun', 'hello');
        //读取缓存
        echo $redis->get('huancun');
    }
}
